<%@ include file="/WEB-INF/jspf/taglib.jspf" %>
<%-- Set language based on user's choice --%>
<c:if test="${!empty language}">
    <fmt:setLocale value="${language}" scope="session" />
</c:if>
<%@ page language="java" import="java.util.*" %>

<%String data = request.getParameter("userlog");%>

<% if (session.getAttribute("isLogin") == "1") {%>
<!--Form Function-->
<script type="text/javascript">
    // pre-submit callback
    function showRequest(formData, jqForm, options) {
        //var queryString = $.param(formData);
        return true;
    }

    // post-submit callback
    function showResponse(responseText, statusText, xhr, $form)  {
        BindJsonToHtml(responseText);
    }
</script>
<!--End Form Function-->

<!--Page Load-->
<script type="text/javascript" >
    $(document).ready(function() {
        /**
         * LoadData
         */

        /**
         * End LoadData
         */

        /**
         * Bind Tab&Dialog
         */

        /**
         * End Bind Tab&Dialog
         */

        /**
         * Bind Event
         */

        /**
         * End Bind Event
         */
    });
</script>
<!--End Page Load-->
<span class="content clearfix">
    <div class="left">
        <h1><fmt:message key="Welcome"/></h1>

        <fmt:message key="Editprofile"/><a onclick="HeaderMenuClick('SRV/MUserDetail', 'section #container', this)"><fmt:message key="click"/> &raquo; </a><br/>
        <input type="button" name="btnLogout" value="Logout" class="bt_login" onclick="ContentAjaxRequest('SEC/Login/doLogout', '#panel')"/>
        <img src="images/user.png"/>
    </div>
    <div class="left">
        <% if ("user".equals(data)) {%>
        <h1>Plan </h1>
        <h2>My Plan</h2>
        <p class="grey">You can find your cure plan from the status, doctor name,...as <a href="javascript:ContentAjaxRequest('SRV/SRV_CureplanList', 'section #container')" title="Download">follows click &raquo;</a></p>
        <%} else if ("doctor".equals(data)) {%>
        <h1>Plan </h1>
        <h2>Doctor Plan</h2>
        <p class="grey">You can find all the services from the price, doctor name, hospital as<a href="javascript:ContentAjaxRequest('SRV/CurePlanProviderList', 'section #container')"> follows click &raquo;</a></p>
        <%} else if ("admin".equals(data)) {%>
        <h1>Master Data</h1>
        <p class="grey">Doctor<a href="javascript:ContentAjaxRequest('SRV/MDoctorList', 'section #container')"> follows click &raquo;</a></p>

        <p class="grey">Hospital<a href="javascript:ContentAjaxRequest('SRV/MHospitalList', 'section #container')"> follows click &raquo;</a></p>

        <p class="grey">Hotel<a href="javascript:ContentAjaxRequest('SRV/MHotelList', 'section #container')"> follows click &raquo;</a></p>

        <p class="grey">Service<a href="javascript:ContentAjaxRequest('SRV/CureServiceList', 'section #container')"> follows click &raquo;</a></p>

        <p class="grey">Doctor Service (ESB)<a href="javascript:ContentAjaxRequest('WebServiceClient/WSC_insertDoctor', 'section #container')"> follows click &raquo;</a></p>

        <p class="grey">Treatment Service (ESB)<a href="javascript:ContentAjaxRequest('WebServiceClient/WSC_insertTreatment', 'section #container')"> follows click &raquo;</a></p>
        <%}%>
    </div>
    <div class="left right">

    </div>
</span>


<% } else {%>
<!--Form Function-->
<script type="text/javascript">
    // pre-submit callback
    function showRequest(formData, jqForm, options) {
        //For Debug form value
        var queryString = $.param(formData);
        alert(queryString);
        return true;
    }

    // post-submit callback
    function showResponse(responseText, statusText, xhr, $form)  {
        alert("success");
        ContentAjaxRequest('SEC/Login', '#panel')
    }
</script>
<!--End Form Function-->

<!--Page Load-->
<script type="text/javascript" >
    $(document).ready(function() {
        /**
         * LoadData
         */
        //Validate Form
        $("#formLogin").validationEngine('attach');
        // attach handler to form's submit event
        $('#formLogin').ajaxForm({
            url: '<%=request.getContextPath()%>/SEC/Login/doLogin',
            type: 'POST',
            dataType:  'json',
            beforeSubmit:  showRequest,  // pre-submit callback
            success:       showResponse  // post-submit callback
        });
                        
        /**
         * End LoadData
         */

        /**
         * Bind Tab&Dialog
         */
        $("#dialogSecLogin_Register").dialog({
            title: "<span class='ui-icon ui-icon-circle-check' style='float: left;'></span> <fmt:message key='Register'/>",
            dialogClass: 'medhub_dialog',
            autoOpen: false,
            width: 450,
            modal: true
        });
        /**
         * End Bind Tab&Dialog
         */

        /**
         * Bind Event
         */
        $( "#btnRegister" )
        .click(function() {
            //if dialogSecLogin_Register was removed from ContentAjaxRequest
            if ($("#dialogSecLogin_Register").length <= 0)
            {
                $("#dialog_panel").html('<div id="dialogSecLogin_Register"></div>');
                $("#dialogSecLogin_Register").dialog({
                    title: "<span class='ui-icon ui-icon-circle-plus' style='float: left;'></span> <fmt:message key='Register'/>",
                    dialogClass: 'medhub_dialog',
                    autoOpen: false,
                    width: 450,
                    modal: true
                });
            }
            ContentAjaxRequest('SEC/Register', '#dialogSecLogin_Register', false);
            $( "#dialogSecLogin_Register" ).dialog( "open" );
        });
        /**
         * End Bind Event
         */
    });
</script>
<!--End Page Load-->
<span class="content clearfix">
    <div class="left">
        <h1><fmt:message key="WelcometoMedicalHub"/></h1>
        <h2><fmt:message key="Login&Register"/></h2>
        <p class="grey"><fmt:message key="Detaillogin"/></p>

    </div>
    <div class="left">
        <!-- Login Form -->
        <form id="formLogin" class="form clearfix">
            <h1><fmt:message key="Login"/></h1>
            <label id="lblLog" class="grey" for="log"><fmt:message key="Username"/>:</label>
            <input class="field validate[required, minSize[8], custom[onlyLetNumSpec]]" type="text" name="log" id="log" value="" />
            <label class="grey" for="pwd"><fmt:message key="Password"/>:</label>
            <input class="field validate[required, minSize[8], maxSize[20]]" type="password" name="pwd" id="pwd" />
            <label>
                <div style="float: left;">
                    <input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> &nbsp;<fmt:message key="Rememberme"/>&nbsp;|&nbsp;
                </div>
                <a class="lost-pwd" href="#"><fmt:message key="Lostpass"/></a>

            </label>
            <div class="clear"></div>
            <div style="float: left;">
                <input type="submit" name="btnLogin" id="btnLogin" class="bt_login" value="Login"  />&nbsp;
            </div>
            <div style="float: left;">
                <input type="button" name="btnRegister" id="btnRegister" class="bt_register" value="Register"  />
            </div>
        </form>
    </div>
    <div class="left right">
        <form action="#" method="post">
            <h1>facebook Login</h1>

        </form>
    </div>
</span>
<div id="dialog_panel">
    <div id="dialogSecLogin_Register" style="display:none;">

    </div>
</div>

<% }%>

